#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=100010;
int main()
{
	int a[maxn],b[maxn],c[maxn],n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<n;i++)
		scanf("%d",&b[i]);
	sort(b,b+n);
	for(int i=0;i<n;i++)
		scanf("%d",&c[i]);
	sort(c,c+n);
	long long sum=0,s1=0,s2=0;
	for(int i=0;i<n;i++){
		while(s1<n&&a[s1]<b[i]) s1++;
        while(s2<n&&c[s2]<=b[i]) s2++;
        sum+=((long long)s1*(n-s2));
    }
	printf("%lld",sum);
	return 0;
}
